<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<div id="stocklist">
<input type="hidden" value="${type }" name="type" id="type"/>
<table width="370" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="110" class="gp_line">
		<c:if test="${'0' eq type}">买</c:if>
		<c:if test="${'1' eq type}">卖</c:if>
		方编号</td>
		<td width="75" class="gp_line">价格</td>
		<td width="75" class="gp_line">数量</td>
		<td width="150" class="gp_line">时间</td>
	</tr>
	<c:forEach var="stock" items="${page.result }">
		<tr>
			<td class="gp_line">${fn:substring(stock.userId, 0, 6)}**</td>
			<td class="gp_line">${stock.price }</td>
			<td class="gp_line">${stock.stockQuantity }</td>
			<td class="gp_line"><fmt:formatDate value="${stock.createDate}" pattern="yyyy-M-dd HH:mm:ss"/>
			</td>
		</tr>
	</c:forEach>
	<tr>
		<td class="gp_line">${fn:substring('cn614489', 0, 6)}**</td>
		<td class="gp_line">0.13</td>
		<td class="gp_line">684</td>
		<td class="gp_line">2014-1-15 20:51:52</td>
	</tr>
	<tr>
		<td class="gp_line">cn6144**</td>
		<td class="gp_line">0.13</td>
		<td class="gp_line">684</td>
		<td class="gp_line">2014-1-15 20:51:52</td>
	</tr>
	<tr>
		<td style="text-align:right;" colspan="4">
		<c:choose>
			<c:when test="${page.pageNo >1}">
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="frontpage(1)">首页</span>
				</a>&nbsp;
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="frontpage(${page.pageNo-1})">上一页</span>
				</a>&nbsp;
			</c:when>
			<c:otherwise>
				首页&nbsp;上一页 &nbsp;
			</c:otherwise>
			</c:choose>
			<c:choose>
				<c:when test="${page.totalPageCount > page.pageNo}">	
					<a href="javascript:void(0);" style="text-decoration: none;">
						<span onclick="nextpage(${page.pageNo+1})">下一页</span> 
					</a>&nbsp;
					<a href="javascript:void(0);" style="text-decoration: none;">
						<span onclick="nextpage(${page.totalPageCount})">末页</span> 
					</a>&nbsp;
				</c:when>
				<c:otherwise>
					下一页&nbsp;末页&nbsp;
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
</table>
</div>
<script type="text/javascript">
function frontpage(pageNo){
	$.ajax({
		type:'POST',
		url: "${ctx}/stocklist.action?pageNo="+pageNo+"&type="+$("#type").val(),
		dataType:"html",
		success: function(data,status){
			if($.trim(data)!=''){
				$("#stocklist").html(data);
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
}

function nextpage(pageNo){
	$.ajax({
		type:'POST',
		url: "${ctx}/stocklist.action?pageNo="+pageNo+"&type="+$("#type").val(),
		dataType:"html",
		success: function(data,status){
			if($.trim(data)!=''){
				$("#stocklist").html(data);
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
}
</script>